﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using JumbotCms.Common;

namespace JumbotCms.WebFile.Writer
{
    public partial class _publish_index : JumbotCms.API.UserCenter
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            User_Load("", "html");
            if (q("act") != "save")
            {
                Response.Write(GetPageHtml("writer_publish"));
            }
            else
            {
                if (!CheckFormUrl())
                    Response.End();
                try
                {
                    doh.Reset();
                    doh.AddFieldItem("Title", f("txtTitle"));
                    doh.AddFieldItem("Title2", f("txtTitle2"));
                    doh.AddFieldItem("Summary", f("txtSummary"));
                    doh.AddFieldItem("Remark", "");
                    doh.AddFieldItem("SourceFrom", f("txtSourceFrom"));
                    doh.AddFieldItem("SourceFrom2", f("txtSourceFrom2"));
                    doh.AddFieldItem("SourceFromUrl2", f("txtSourceFromUrl2"));
                    doh.AddFieldItem("ArmsId", Str2Str(f("ddlArmsId")));
                    doh.AddFieldItem("Author", f("txtAuthor"));
                    doh.AddFieldItem("Author2", f("txtAuthor2"));
                    doh.AddFieldItem("AuthorSummary", GetCutString(Jumbot.Common.Strings.HtmlEncode(f("txtAuthorSummary")), 1000));
                    doh.AddFieldItem("AuthorSummary2", GetCutString(Jumbot.Common.Strings.HtmlEncode(f("txtAuthorSummary2")), 1000));
                    doh.AddFieldItem("Translator", "[" + UserName + "]");
                    doh.AddFieldItem("Tags", f("txtTags"));
                    doh.AddFieldItem("UserId", UserId);
                    doh.AddFieldItem("Countries", f("txtCountries"));
                    doh.AddFieldItem("WordCount", f("txtWordCount"));
                    doh.AddFieldItem("WordCount2", f("txtWordCount2"));
                    doh.AddFieldItem("DownUrl1", f("txtDownUrl1"));
                    doh.AddFieldItem("DownUrl2", f("txtDownUrl2"));
                    doh.AddFieldItem("State", 2);
                    doh.AddFieldItem("IsLocked", 0);
                    doh.AddFieldItem("ChannelId", Str2Int(f("ddlChannelId")));
                    doh.AddFieldItem("SortId", Str2Int(f("ddlSortId")));
                    doh.AddFieldItem("AddDate", DateTime.Now.ToString());
                    doh.Insert("jcms_module_version_source");
                    Response.Write("JumbotCms.Alert('发布成功,等待受理', '1', \"window.location='" + site.Dir + "writer/index/index.aspx?mod=writer';\");");
                }
                catch (Exception ex)
                {
                    Response.Write("JumbotCms.Alert('发布错误', '0', \"alert('错误信息," + Jumbot.Common.Strings.SafetyStr(ex.Message) + "')\");");
                }
            }
        }
    }
}
